home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / game / shoot / WarpQuake_src.lha / WarpQuakeSrc / vid_amiga.c < prev    next >
C/C++ Source or Header  |  2000-03-02  |  17KB  |  707 lines

  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  12.  
  13. See the GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. */
  20. // vid_amiga.c -- amiga video driver
  21.  
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <signal.h>
  25.  
  26. #include <exec/exec.h>
  27. #include <graphics/gfx.h>
  28. #include <intuition/intuition.h>
  29. #include <libraries/asl.h>
  30. #include <cybergraphics/cybergraphics.h>
  31. #include <utility/tagitem.h>
  32.  
  33. #include <clib/chunkyppc_protos.h>
  34. #include <powerup/ppcproto/exec.h>
  35. #include <powerup/ppcproto/graphics.h>
  36. #include <powerup/ppcproto/intuition.h>
  37. #include <powerup/ppcproto/asl.h>
  38.  
  39. #include "quakedef.h"
  40. #include "d_local.h"
  41.  
  42. #ifdef PPC
  43. extern void ppc_c2p_line (int line, int src, struct BitMap *dst, int cnt);
  44. #endif
  45.  
  46. extern qboolean using_mouse;
  47. extern short int last_mouse[2];
  48. qboolean mousemove = false;
  49. qboolean fastaga = false;
  50. qboolean force = false;
  51. qboolean nodb = false;
  52. qboolean wpa8 = false;
  53.  
  54. #define    BASEWIDTH    320
  55. #define    BASEHEIGHT    200
  56.  
  57. pixel_t *vid_buffer;
  58. short *zbuffer;
  59. byte *surfcache;
  60.  
  61. unsigned short    d_8to16table[256];
  62.  
  63. /**********************************************************************/
  64.  
  65. struct GfxBase *GfxBase = NULL;
  66. struct IntuitionBase *IntuitionBase = NULL;
  67. struct Library *ChunkyPPCBase = NULL;
  68. struct Library *AslBase = NULL;
  69.  
  70. static struct ScreenBuffer *sbuffer[3] = {NULL, NULL, NULL};
  71. static struct ScreenBuffer *nextsbuffer = NULL;
  72. static struct Mode_Screen ms;
  73. struct Mode_Screen *msptr = &ms;
  74. static struct Screen *video_screen = NULL;
  75. static struct Window *video_window = NULL;
  76. static struct ScreenModeRequester *smr = NULL;
  77. static struct RastPort rp;
  78. static struct RastPort temprp;
  79. static struct BitMap *next_bm;
  80. static unsigned char *next_sbuf;
  81. static struct BitMap tmp_bm = {
  82.   0, 0, 0, 0, 0, {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
  83. };
  84.  
  85. static UWORD *emptypointer = NULL;
  86. static BOOL is_cyber_mode = FALSE;
  87. static BOOL is_native_mode = FALSE;
  88.  
  89. /**********************************************************************/
  90. void    VID_SetPalette (unsigned char *palette)
  91. {
  92.   int i;
  93.   ULONG v;
  94.   static ULONG colourtable[1+3*256+1];
  95.  
  96.   colourtable[0] = (256 << 16) + 0;
  97.   for (i = 0; i < 3*256; i++) {
  98.     v = *palette++;
  99.     v += (v << 8);
  100.     v += (v << 16);
  101.     colourtable[i+1] = v;
  102.   }
  103.   colourtable[1 + 3*256] = 0;
  104.     if ((fastaga) || (wpa8))
  105.         LoadRGB32 (&video_screen->ViewPort, colourtable);
  106.     else
  107.       LoadColors (&ms, colourtable);
  108. }
  109.  
  110. /**********************************************************************/
  111. void    VID_ShiftPalette (unsigned char *palette)
  112. {
  113.   VID_SetPalette (palette);
  114. }
  115.  
  116. /****************************************************************************/
  117. void    VID_Init (unsigned char *palette)
  118. {
  119.   int mode, d;
  120.     int width = 0, height = 0;
  121.     int w, h;
  122.     ULONG idcmp, flags, propertymask;
  123.     struct TagItem stags[7];
  124.     struct TagItem wtags[8];
  125.     struct TagItem atags[12];
  126.  
  127.     fastaga = COM_CheckParm ("-aga");
  128.     force = COM_CheckParm ("-force");
  129.     nodb = COM_CheckParm ("-nodb");
  130.     wpa8 = COM_CheckParm ("-wpa8");
  131.  
  132.     if ((!fastaga) && (!wpa8))
  133.         ChunkyPPCBase = OpenLibrary("chunkyppc.library", 3);
  134.  
  135.     (struct Library *)GfxBase = OpenLibrary("graphics.library", 39);
  136.  
  137.     (struct Library *)IntuitionBase = OpenLibrary("intuition.library", 39);
  138.  
  139.     AslBase = OpenLibrary("asl.library", 38);
  140.  
  141.     if ((!fastaga) && (!wpa8))
  142.     {
  143.         if (ChunkyPPCBase == NULL)
  144.             Sys_Error ("Can't open chunkyppc.library V3\n");
  145.     }
  146.  
  147.     if (GfxBase == NULL)
  148.         Sys_Error ("Can't open graphics.library V39\n");
  149.  
  150.     if (IntuitionBase == NULL)
  151.         Sys_Error ("Can't open intuition.library V39\n");
  152.  
  153.     if ((AslBase = OpenLibrary ("asl.library", 38L)) == NULL ||
  154.       (smr = AllocAslRequest (ASL_ScreenModeRequest, NULL)) == NULL)
  155.     Sys_Error ("OpenLibrary(""asl.library"", 38) failed");
  156.  
  157.     if ((fastaga) || (wpa8))
  158.     {
  159.         if (fastaga)
  160.             is_native_mode = TRUE;
  161.  
  162.         propertymask = DIPF_IS_EXTRAHALFBRITE | DIPF_IS_DUALPF | DIPF_IS_PF2PRI |
  163.                                      DIPF_IS_HAM;
  164.  
  165.         atags[0].ti_Tag = ASLSM_TitleText;
  166.         atags[0].ti_Data = (ULONG)"WarpQuake";
  167.         atags[1].ti_Tag = ASLSM_MinWidth;
  168.         atags[1].ti_Data = BASEWIDTH;
  169.         atags[2].ti_Tag = ASLSM_MinHeight;
  170.         atags[2].ti_Data = BASEHEIGHT;
  171.         atags[3].ti_Tag = ASLSM_InitialDisplayWidth;
  172.         atags[3].ti_Data = BASEWIDTH;
  173.         atags[4].ti_Tag = ASLSM_InitialDisplayHeight;
  174.         atags[4].ti_Data = BASEHEIGHT;
  175.         atags[5].ti_Tag = ASLSM_MinDepth;
  176.         atags[5].ti_Data = 8;
  177.         atags[6].ti_Tag = ASLSM_MaxDepth;
  178.         atags[6].ti_Data = 8;
  179.         atags[7].ti_Tag = ASLSM_DoWidth;
  180.         atags[7].ti_Data = TRUE;
  181.         atags[8].ti_Tag = ASLSM_DoHeight;
  182.         atags[8].ti_Data = TRUE;
  183.         atags[9].ti_Tag = ASLSM_PropertyMask;
  184.         atags[9].ti_Data = propertymask;
  185.         atags[10].ti_Tag = ASLSM_PropertyFlags;
  186.         atags[10].ti_Data = 0;
  187.         atags[11].ti_Tag = TAG_DONE;
  188.         atags[11].ti_Data = 0;
  189.  
  190.         if((AslRequest (smr, atags)) == NULL)
  191.             Sys_Error ("AslRequest() failed\n");
  192.  
  193.         mode = smr->sm_DisplayID;
  194.         width = smr->sm_DisplayWidth;
  195.         height = smr->sm_DisplayHeight;
  196.  
  197.         stags[0].ti_Tag = SA_Type;
  198.         stags[0].ti_Data = CUSTOMSCREEN;
  199.         stags[1].ti_Tag = SA_DisplayID;
  200.         stags[1].ti_Data = mode;
  201.         stags[2].ti_Tag = SA_Width;
  202.         stags[2].ti_Data = width;
  203.         stags[3].ti_Tag = SA_Height;
  204.         stags[3].ti_Data = height;
  205.         stags[4].ti_Tag = SA_Depth;
  206.         stags[4].ti_Data = 8;
  207.         stags[5].ti_Tag = SA_Quiet;
  208.         stags[5].ti_Data = TRUE;
  209.         stags[6].ti_Tag = TAG_END;
  210.         stags[6].ti_Data = 0;
  211.  
  212.         if((video_screen = OpenScreenTagList (NULL, stags)) == NULL)
  213.             Sys_Error ("OpenScreenTagList() failed\n");
  214.  
  215.         idcmp = IDCMP_RAWKEY;
  216.         flags = WFLG_ACTIVATE | WFLG_BORDERLESS | WFLG_NOCAREREFRESH |
  217.               WFLG_SIMPLE_REFRESH;
  218.       if (using_mouse)
  219.         {
  220.         idcmp |= IDCMP_MOUSEBUTTONS | IDCMP_DELTAMOVE | IDCMP_MOUSEMOVE;
  221.         flags |= WFLG_RMBTRAP | WFLG_REPORTMOUSE;
  222.       }
  223.  
  224.         wtags[0].ti_Tag = WA_Left;
  225.         wtags[0].ti_Data = 0;
  226.         wtags[1].ti_Tag = WA_Top;
  227.         wtags[1].ti_Data = 0;
  228.         wtags[2].ti_Tag = WA_Width;
  229.         wtags[2].ti_Data = width;
  230.         wtags[3].ti_Tag = WA_Height;
  231.         wtags[3].ti_Data = height;
  232.         wtags[4].ti_Tag = WA_IDCMP;
  233.         wtags[4].ti_Data = idcmp;
  234.         wtags[5].ti_Tag = WA_Flags;
  235.         wtags[5].ti_Data = flags;
  236.         wtags[6].ti_Tag = WA_CustomScreen;
  237.         wtags[6].ti_Data = (ULONG) video_screen;
  238.         wtags[7].ti_Tag = TAG_DONE;
  239.         wtags[7].ti_Data = 0;
  240.  
  241.         if((video_window = OpenWindowTagList (NULL, wtags)) == NULL)
  242.             Sys_Error ("OpenWindowTagList() failed\n");
  243.  
  244.         if ((emptypointer = AllocVec (16, MEMF_CHIP | MEMF_CLEAR)) == NULL)
  245.             Sys_Error ("Couldn't allocate chip memory for pointer");
  246.         SetPointer (video_window, emptypointer, 1, 16, 0, 0);
  247.  
  248.         InitRastPort (&rp);
  249.         rp.BitMap = video_screen->ViewPort.RasInfo->BitMap;
  250.  
  251.         if (wpa8)
  252.         {
  253.             InitBitMap (&tmp_bm, 8, width, 1);
  254.             for (d = 0; d < 8; d++)
  255.                 if ((tmp_bm.Planes[d] = (PLANEPTR)AllocRaster (width, 1)) == NULL)
  256.                     Sys_Error ("AllocRaster() failed");
  257.             temprp = *video_window->RPort;
  258.             temprp.Layer = NULL;
  259.             temprp.BitMap = &tmp_bm;
  260.         }
  261.  
  262.         if ((!nodb) && (!wpa8))
  263.         {
  264.             if (((sbuffer[0] = AllocScreenBuffer (video_screen, NULL, SB_SCREEN_BITMAP)) == NULL) |
  265.             ((sbuffer[1] = AllocScreenBuffer (video_screen, NULL, NULL)) == NULL ||
  266.             (sbuffer[2] = AllocScreenBuffer (video_screen, NULL, NULL)) == NULL))
  267.           Sys_Error ("AllocScreenBuffer() failed");
  268.         nextsbuffer = sbuffer[1];
  269.             rp.BitMap = nextsbuffer->sb_BitMap;
  270.         }
  271.     }
  272.     else
  273.     {
  274.         w = COM_CheckParm ("-width");
  275.         if (w)
  276.         {
  277.             if (w < com_argc-1)
  278.                 ms.SCREENWIDTH = Q_atoi (com_argv[w+1]);
  279.             else
  280.                 Sys_Error ("You must specify a size after -width");
  281.         }
  282.         else
  283.             ms.SCREENWIDTH = BASEWIDTH;
  284.  
  285.         h = COM_CheckParm ("-height");
  286.         if (h)
  287.         {
  288.             if (h < com_argc-1)
  289.                 ms.SCREENHEIGHT = Q_atoi (com_argv[h+1]);
  290.             else
  291.                 Sys_Error ("You must specify a size after -height");
  292.         }
  293.         else
  294.             ms.SCREENHEIGHT = BASEHEIGHT;
  295.  
  296.         ms.MS_MAXWIDTH = 1280;
  297.         ms.MS_MAXHEIGHT = 1024;
  298.         ms.MAXDEPTH = 8;
  299.         ms.MINDEPTH = 8;
  300.         ms.video_screen = 0;
  301.         ms.video_window = 0;
  302.  
  303.         if (force)
  304.             msptr = OpenGraphics ("WarpQuake", &ms, 1);
  305.         else
  306.             msptr = OpenGraphics ("WarpQuake", &ms, 0);
  307.  
  308.         if (!msptr)
  309.             Sys_Error ("OpenGraphics() failed\n");
  310.  
  311.         if (!(ChunkyInit(&ms,PIXFMT_LUT8)))
  312.             Sys_Error ("ChunkyInit() failed\n");
  313.  
  314.         if (ms.video_is_native_mode)
  315.         {
  316.             is_native_mode = TRUE;
  317.             if (ms.numbuffers == 1)
  318.                 next_bm = ms.bitmapa;
  319.             else
  320.                 next_bm = ms.bitmapb;
  321.         }
  322.         else
  323.         {
  324.             if (ms.video_is_cyber_mode)
  325.                 is_cyber_mode = TRUE;
  326.             if (ms.numbuffers == 1)
  327.                 next_sbuf = ms.screen;
  328.             else
  329.                 next_sbuf = ms.screenb;
  330.         }
  331.  
  332.       mode = ms.mode;
  333.       width = ms.SCREENWIDTH;
  334.       height = ms.SCREENHEIGHT;
  335.         video_window = ms.video_window;
  336.  
  337. #ifdef DEBUG
  338.         printf("ms.SCREENWIDTH: %i\n", ms.SCREENWIDTH);
  339.         printf("ms.SCREENHEIGHT: %i\n", ms.SCREENHEIGHT);
  340. #endif
  341.  
  342.       Con_Printf ("Screen Mode $%08x is", mode);
  343.       if (is_native_mode)
  344.         Con_Printf (" NATIVE-PLANAR");
  345.       else
  346.         Con_Printf (" FOREIGN");
  347.       Con_Printf (" 8-BIT");
  348.       if (is_cyber_mode)
  349.         Con_Printf (" CYBERGRAPHX");
  350.       Con_Printf (", using size %d x %d\n", width, height);
  351.  
  352.         if (!using_mouse)
  353.         {
  354.             if(!(ModifyIDCMP(ms.video_window, IDCMP_RAWKEY)))
  355.                 Sys_Error ("ModifyIDCMP() failed\n");
  356.         }
  357.     }
  358.  
  359.   if ((vid_buffer = (pixel_t *)malloc(sizeof(pixel_t) *
  360.                                       width * height)) == NULL ||
  361.       (zbuffer = (short *)malloc(sizeof(short) * width * height)) == NULL ||
  362.       (surfcache = (byte *)malloc(sizeof(byte) *
  363.                                   (width*height/(320*200))*256*1024*2)) == NULL)
  364.             Sys_Error ("Out of memory");
  365.  
  366.   vid.width = vid.conwidth = width;
  367.   vid.height = vid.conheight = height;
  368.   vid.maxwarpwidth = WARP_WIDTH;
  369.   vid.maxwarpheight = WARP_HEIGHT;
  370.   vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);
  371.     if (wpa8)
  372.         vid.numpages = 1;
  373.     else if (fastaga)
  374.         if (nodb)
  375.             vid.numpages = 1;
  376.         else
  377.             vid.numpages = 3;
  378.     else
  379.       vid.numpages = ms.numbuffers;
  380.   vid.colormap = host_colormap;
  381.   vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
  382.   vid.buffer = vid.conbuffer = vid_buffer;
  383.   vid.rowbytes = vid.conrowbytes = width;
  384.   vid.direct = NULL;
  385.  
  386.   d_pzbuffer = zbuffer;
  387.   D_InitCaches (surfcache, sizeof(byte) *
  388.                            (width*height/(320*200))*256*1024*2);
  389.  
  390.   VID_SetPalette (palette);
  391.  
  392. }
  393.  
  394. /**********************************************************************/
  395. void    VID_Shutdown (void)
  396. {
  397.     int d;
  398.  
  399. //  printf ("VID_Shutdown\n");
  400.   if (surfcache != NULL)
  401.     {
  402.     free (surfcache);
  403.     surfcache = NULL;
  404.   }
  405.  
  406.   if (zbuffer != NULL)
  407.     {
  408.     free (zbuffer);
  409.     zbuffer = NULL;
  410.   }
  411.  
  412.   if (vid_buffer != NULL)
  413.     {
  414.     free (vid_buffer);
  415.     vid_buffer = NULL;
  416.   }
  417.  
  418.     if (sbuffer[0] != NULL)
  419.     {
  420.         ChangeScreenBuffer (video_screen, sbuffer[0]);
  421.     WaitTOF ();
  422.     WaitTOF ();
  423.         FreeScreenBuffer (video_screen, sbuffer[0]);
  424.         sbuffer[0] = NULL;
  425.     }
  426.  
  427.     if (sbuffer[1] != NULL)
  428.     {
  429.         FreeScreenBuffer (video_screen, sbuffer[1]);
  430.         sbuffer[1] = NULL;
  431.     }
  432.  
  433.     if (sbuffer[2] != NULL)
  434.     {
  435.         FreeScreenBuffer (video_screen, sbuffer[2]);
  436.         sbuffer[2] = NULL;
  437.     }
  438.  
  439.     if ((fastaga) || (wpa8))
  440.     {
  441.         if (video_window != NULL)
  442.         {
  443.             ClearPointer (video_window);
  444.             CloseWindow (video_window);
  445.             video_window = NULL;
  446.         }
  447.     }
  448.  
  449.     if (emptypointer != NULL)
  450.     {
  451.         FreeVec (emptypointer);
  452.         emptypointer = NULL;
  453.     }
  454.  
  455.     if (video_screen != NULL)
  456.     {
  457.         CloseScreen (video_screen);
  458.         video_screen = NULL;
  459.     }
  460.  
  461.     for (d = 0; d < 8; d++)
  462.     {
  463.       if (tmp_bm.Planes[d] != NULL)
  464.         {
  465.         FreeRaster (tmp_bm.Planes[d], vid.width, 1);
  466.             tmp_bm.Planes[d] = NULL;
  467.         }
  468.     }
  469.  
  470.     if (smr != NULL)
  471.     {
  472.         FreeAslRequest (smr);
  473.         smr = NULL;
  474.     }
  475.  
  476.     if (msptr != NULL)
  477.     {
  478.         CloseGraphics (msptr, 1);
  479.         msptr = NULL;
  480.     }
  481.  
  482.     if (AslBase != NULL)
  483.     {
  484.         CloseLibrary (AslBase);
  485.         AslBase = NULL;
  486.     }
  487.  
  488.     if (ChunkyPPCBase != NULL)
  489.     {
  490.         CloseLibrary (ChunkyPPCBase);
  491.         ChunkyPPCBase = NULL;
  492.     }
  493.  
  494.     if (GfxBase != NULL)
  495.     {
  496.         CloseLibrary ((struct Library *)GfxBase);
  497.         GfxBase = NULL;
  498.     }
  499.  
  500.     if (IntuitionBase != NULL)
  501.     {
  502.         CloseLibrary ((struct Library *)IntuitionBase);
  503.         IntuitionBase = NULL;
  504.     }
  505. }
  506.  
  507. /**********************************************************************/
  508. void    VID_Update (vrect_t *rects)
  509. {
  510.   int i, j;
  511.  
  512.     if (is_native_mode)
  513.     {
  514.         if (fastaga)
  515.         {
  516.             while (rects != NULL)
  517.             {
  518.                 for (i = rects->y, j = ((int)(vid_buffer)) + rects->y * vid.width;
  519.                                           i < rects->y + rects->height; i++, j += vid.width)
  520.             ppc_c2p_line (i, j, rp.BitMap, (vid.width + 31) >> 5);
  521.                 rects = rects->pnext;
  522.             }
  523.             if (!nodb)
  524.             {
  525.                 if (ChangeScreenBuffer (video_screen, nextsbuffer))
  526.                 {
  527.               if (nextsbuffer == sbuffer[0])
  528.                 nextsbuffer = sbuffer[1];
  529.               else if (nextsbuffer == sbuffer[1])
  530.                 nextsbuffer = sbuffer[2];
  531.                     else
  532.                         nextsbuffer = sbuffer[0];
  533.                     rp.BitMap = nextsbuffer->sb_BitMap;
  534.                 }
  535.             }
  536.         }
  537.         else
  538.         {
  539.             while (rects != NULL)
  540.             {
  541.                 CallChunkyCopy (&ms, (unsigned char *) next_bm, (void *) vid_buffer,
  542.                                                 PIXFMT_LUT8, 0, 0);
  543.                 if (ms.numbuffers == 2)
  544.                 {
  545.                     if (next_bm == ms.bitmapa)
  546.                         next_bm = ms.bitmapb;
  547.                     else
  548.                         next_bm = ms.bitmapa;
  549.                 }
  550.                 else if (ms.numbuffers == 3)
  551.                 {
  552.                     if (next_bm == ms.bitmapa)
  553.                         next_bm = ms.bitmapb;
  554.                     else if (next_bm == ms.bitmapb)
  555.                         next_bm = ms.bitmapc;
  556.                     else
  557.                         next_bm = ms.bitmapa;
  558.                 }
  559.                 rects = rects->pnext;
  560.             }
  561.             DoubleBuffer (&ms);
  562.         }
  563.     }
  564.     else if (wpa8)
  565.     {
  566.         while (rects != NULL)
  567.         {
  568.             WritePixelArray8 (video_window->RPort, rects->x, rects->y,
  569.                           rects->x + rects->width - 1,
  570.                           rects->y + rects->height - 1,
  571.                           vid_buffer, &temprp);
  572.             rects = rects->pnext;
  573.         }
  574.     }
  575.     else
  576.     {
  577.         while (rects != NULL)
  578.         {
  579.             CallChunkyCopy (&ms, next_sbuf, (void *) vid_buffer, PIXFMT_LUT8, 0, 0);
  580.             if (ms.numbuffers == 2)
  581.             {
  582.                 if (next_sbuf == ms.screen)
  583.                     next_sbuf = ms.screenb;
  584.                 else
  585.                     next_sbuf = ms.screen;
  586.             }
  587.             else if (ms.numbuffers == 3)
  588.             {
  589.                 if (next_sbuf == ms.screen)
  590.                     next_sbuf = ms.screenb;
  591.                 else if (next_sbuf == ms.screenb)
  592.                     next_sbuf = ms.screenc;
  593.                 else
  594.                     next_sbuf = ms.screen;
  595.             }
  596.             rects = rects->pnext;
  597.         }
  598.         DoubleBuffer (&ms);
  599.     }
  600. }
  601.  
  602. /**********************************************************************/
  603. /*
  604. ================
  605. D_BeginDirectRect
  606. ================
  607. */
  608.  
  609. void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
  610. {
  611. }
  612.  
  613. /**********************************************************************/
  614. /*
  615. ================
  616. D_EndDirectRect
  617. ================
  618. */
  619. void D_EndDirectRect (int x, int y, int width, int height)
  620. {
  621. }
  622.  
  623. /**********************************************************************/
  624. void Sys_SendKeyEvents(void)
  625. {
  626.   UWORD code;
  627.     ULONG class;
  628.     WORD mousex, mousey;
  629.   struct IntuiMessage *msg;
  630.   static int xlate[0x68] = {
  631.     '`', '1', '2', '3', '4', '5', '6', '7',
  632.     '8', '9', '0', '-', '=', '\\', 0, '0',
  633.     'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
  634.     'o', 'p', K_F11, K_F12, 0, '0', '2', '3',
  635.     'a', 's', 'd', 'f', 'g', 'h', 'j', 'k',
  636.     'l', ';', '\'', K_ENTER, 0, '4', '5', '6',
  637.     K_SHIFT, 'z', 'x', 'c', 'v', 'b', 'n', 'm',
  638.     ',', '.', '/', 0, '.', '7', '8', '9',
  639.     K_SPACE, K_BACKSPACE, K_TAB, K_ENTER, K_ENTER, K_ESCAPE, K_F11,
  640.     0, 0, 0, '-', 0, K_UPARROW, K_DOWNARROW, K_RIGHTARROW, K_LEFTARROW,
  641.     K_F1, K_F2, K_F3, K_F4, K_F5, K_F6, K_F7, K_F8,
  642.     K_F9, K_F10, '(', ')', '/', '*', '=', K_PAUSE,
  643.     K_SHIFT, K_SHIFT, 0, K_CTRL, K_ALT, K_ALT, 0, K_CTRL
  644.   };
  645.  
  646.     if (video_window !=NULL )
  647.     {
  648.         while ((msg = (struct IntuiMessage *)GetMsg (video_window->UserPort)) != NULL)
  649.         {
  650.       class = msg->Class;
  651.       code = msg->Code;
  652.       mousex = msg->MouseX;
  653.       mousey = msg->MouseY;
  654.       ReplyMsg ((struct Message *)msg);
  655.       switch (class)
  656.             {
  657.         case IDCMP_RAWKEY:
  658.           if ((code & 0x80) != 0)
  659.                     {
  660.             code &= ~0x80;
  661.             if (code < 0x68)
  662.               Key_Event (xlate[code], false);
  663.           }
  664.                     else 
  665.                     {
  666.             if (code < 0x68)
  667.               Key_Event (xlate[code], true);
  668.           }
  669.           break;
  670.         case IDCMP_MOUSEBUTTONS:
  671.                     switch (code)
  672.                     {
  673.                       case IECODE_LBUTTON:
  674.                         Key_Event (K_MOUSE1, true);
  675.                             break;
  676.                     case IECODE_LBUTTON + IECODE_UP_PREFIX:
  677.                       Key_Event (K_MOUSE1, false);
  678.                       break;
  679.                     case IECODE_MBUTTON:
  680.                       Key_Event (K_MOUSE2, true);
  681.                       break;
  682.                     case IECODE_MBUTTON + IECODE_UP_PREFIX:
  683.                       Key_Event (K_MOUSE2, false);
  684.                       break;
  685.                     case IECODE_RBUTTON:
  686.                       Key_Event (K_MOUSE3, true);
  687.                       break;
  688.                     case IECODE_RBUTTON + IECODE_UP_PREFIX:
  689.                       Key_Event (K_MOUSE3, false);
  690.                       break;
  691.                         default:
  692.                             break;
  693.                     }
  694.         case IDCMP_MOUSEMOVE:                                    // Handled in in_amiga.c
  695.           last_mouse[0] = mousex;
  696.           last_mouse[1] = mousey;
  697.                     mousemove = true;
  698.           break;
  699.         default:
  700.           break;
  701.       }
  702.     }
  703.   }
  704. }
  705.  
  706. /**********************************************************************/
  707.